home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc19 / gemfsc19.lzh / GNUGEM27 / AESGRAF.C < prev    next >
C/C++ Source or Header  |  1993-03-24  |  7KB  |  330 lines

  1. /*
  2.  *    Aes graphics library interface
  3.  *
  4.  *        graf_rubberbox    Draw a rubber box
  5.  *        graf_dragbox    Drag a box within a boundary
  6.  *        graf_movebox    Move a box
  7.  *        graf_growbox    Draw an expanding box outline
  8.  *        graf_shrinkbox    Draw a shrinking box outline
  9.  *        graf_watchbox    Track mouse in/out of a box
  10.  *        graf_slidebox    Track sliding box in a parent box
  11.  *        graf_handle     Get VDI handle
  12.  *        graf_mouse        Change Mouse Form
  13.  *        graf_mkstate    Get mouse and keyboard state
  14.  *
  15.  *        ++jrb    bammi@cadence.com
  16.  *        modified: mj -- ntomczak@vm.ucs.ualberta.ca
  17.  */
  18. #include "common.h"
  19.  
  20. #ifdef __DEF_ALL__
  21.  
  22. #define L_graf_rub
  23. #define L_graf_dra
  24. #define L_graf_mov
  25. #define L_graf_gro
  26. #define L_graf_shr
  27. #define L_graf_wat
  28. #define L_graf_sli
  29. #define L_graf_han
  30. #define L_graf_mou
  31. #define L_graf_mks
  32.  
  33. #endif /* __DEF_ALL__ */
  34.  
  35.  
  36. #ifdef L_graf_rub
  37.  
  38. /* Draw a rubber box
  39.  *    input initial position and size of the rubber-box [Ix,Iy, Iw,Ih].
  40.  * output Final Size (Fw,Fh).
  41.  * control returns when left mouse button is released.
  42.  *
  43.  *    return == 0 error    >0 no error
  44.  */
  45. int graf_rubberbox(int Ix,    int Iy, int Iw, int Ih,
  46.            int *Fw, int *Fh)
  47. {
  48.     int retval;
  49.  
  50.     _int_in[0] = Ix;
  51.     _int_in[1] = Iy;
  52.     _int_in[2] = Iw;
  53.     _int_in[3] = Ih;
  54.  
  55.     retval = __aes__(AES_CONTROL_ENCODE(70, 4, 3, 0));
  56.  
  57.     *Fw = _int_out[1];
  58.     *Fh = _int_out[2];
  59.  
  60.     return retval;
  61. }
  62. #endif /* L_graf_rub */
  63.  
  64.  
  65. #ifdef L_graf_dra
  66.  
  67. /* Drag a box in boundary
  68.  *    Sw = Width of box being dragged
  69.  *    Sh = Height of box being dragged
  70.  *    Sx = Starting X pos of box being dragged
  71.  *    Sy = Starting Y pos of box being dragged
  72.  *    Bx = X position of boundary
  73.  *    By = Y position of boundary
  74.  *    Bw = Width of bounday
  75.  *    Bh = Height of boundary
  76.  *    Fw = Final X position of box in boundary
  77.  *    Fh = Final Y position of box in boundary
  78.  *    control returns on mouse button release
  79.  *
  80.  *    return == 0 error    >0 no error
  81.  */
  82. int graf_dragbox(int Sw, int Sh, int Sx, int Sy,    /* inputs  */
  83.          int Bx, int By, int Bw, int Bh,
  84.          int *Fw, int *Fh)            /* outputs */
  85. {
  86.     int retval;
  87.  
  88.     _int_in[0] = Sw;
  89.     _int_in[1] = Sh;
  90.     _int_in[2] = Sx;
  91.     _int_in[3] = Sy;
  92.     _int_in[4] = Bx;
  93.     _int_in[5] = By;
  94.     _int_in[6] = Bw;
  95.     _int_in[7] = Bh;
  96.  
  97.     retval = __aes__(AES_CONTROL_ENCODE(71, 8, 3, 0));
  98.  
  99.     *Fw = _int_out[1];
  100.     *Fh = _int_out[2];
  101.  
  102.     return retval;
  103. }
  104. #endif /* L_graf_dra */
  105.  
  106.  
  107. #ifdef L_graf_mov
  108.  
  109. /* Move a box
  110.  *    from Sx,Sy to Dx,Dy
  111.  *    Sw = Width of Box
  112.  *    Sh = Height of Box
  113.  *
  114.  *    return == 0 error    >0 no error
  115.  */
  116. int graf_movebox(int Sw, int Sh, int Sx, int Sy, int Dx, int Dy)
  117. {
  118.     _int_in[0] = Sw;
  119.     _int_in[1] = Sh;
  120.     _int_in[2] = Sx;
  121.     _int_in[3] = Sy;
  122.     _int_in[4] = Dx;
  123.     _int_in[5] = Dy;
  124.  
  125.     return __aes__(AES_CONTROL_ENCODE(72, 6, 1, 0));
  126. }
  127. #endif /* L_graf_mov */
  128.  
  129.  
  130. #ifdef L_graf_gro
  131.  
  132. /* Draw an expanding outline
  133.  *    Sx = Start X
  134.  *    Sy = Start Y
  135.  *    Sw = Start Width
  136.  *    Sh = Start Height
  137.  *    Fx = Final X
  138.  *    Fy = Final Y
  139.  *    Fw = Final Width
  140.  *    Fh = Final Height
  141.  *
  142.  *    return == 0 error    >0 no error
  143.  */
  144. int graf_growbox(int Sx, int Sy, int Sw, int Sh,
  145.          int Fx, int Fy, int Fw, int Fh)
  146. {
  147.     _int_in[0] = Sx;
  148.     _int_in[1] = Sy;
  149.     _int_in[2] = Sw;
  150.     _int_in[3] = Sh;
  151.  
  152.     _int_in[4] = Fx;
  153.     _int_in[5] = Fy;
  154.     _int_in[6] = Fw;
  155.     _int_in[7] = Fh;
  156.  
  157.     return __aes__(AES_CONTROL_ENCODE(73, 8, 1, 0));
  158. }
  159. #endif /* L_graf_gro */
  160.  
  161.  
  162. #ifdef L_graf_shr
  163.  
  164. /* Draw a shrinking outline
  165.  *    Fx = Final X
  166.  *    Fy = Final Y
  167.  *    Fw = Final Width
  168.  *    Fh = Final Height
  169.  *    Sx = Start X
  170.  *    Sy = Start Y
  171.  *    Sw = Start Width
  172.  *    Sh = Start Height
  173.  *
  174.  *    return == 0 error    >0 no error
  175.  */
  176. int graf_shrinkbox(int Fx, int Fy, int Fw, int Fh,
  177.            int Sx, int Sy, int Sw, int Sh)
  178. {
  179.     _int_in[0] = Fx;
  180.     _int_in[1] = Fy;
  181.     _int_in[2] = Fw;
  182.     _int_in[3] = Fh;
  183.  
  184.     _int_in[4] = Sx;
  185.     _int_in[5] = Sy;
  186.     _int_in[6] = Sw;
  187.     _int_in[7] = Sh;
  188.  
  189.     return __aes__(AES_CONTROL_ENCODE(74, 8, 1, 0));
  190. }
  191. #endif /* L_graf_shr */
  192.  
  193.  
  194. #ifdef L_graf_wat
  195.  
  196. /* Track mouse
  197.  *    Tree = Addr of object tree containing the box
  198.  *    Object = Index of Object in tree
  199.  *    InState = Box state when mouse is inside
  200.  *    OutState = Box state when mouse is outside
  201.  *
  202.  *    Returns on mouse button release
  203.  *    Return = 0 if release outside box
  204.  *    Return = 1 if release inside box.
  205.  *
  206.  * Values for state: (combinations possible)
  207.  *     0    Normal
  208.  *     1    Selected
  209.  *     2    Crossed
  210.  *     4    Checked
  211.  *     8    Disabled
  212.  *    16    Outlined
  213.  *    32    Shadowed
  214.  *
  215.  */
  216. int graf_watchbox(void *Tree,
  217.           int Object, int InState, int OutState)
  218. {
  219.     _addrin[0] = Tree;
  220.     _int_in[0]    = 0;        /* reserved */
  221.     _int_in[1]    = Object;
  222.     _int_in[2]    = InState;
  223.     _int_in[3]    = OutState;
  224.  
  225.     return __aes__(AES_CONTROL_ENCODE(75, 4, 1, 1));
  226. }
  227. #endif /* L_graf_wat */
  228.  
  229.  
  230. #ifdef L_graf_sli
  231.  
  232. /* Track slider in box
  233.  *    Tree = Addr of tree containing Box & Slider
  234.  *    Parent = Index of Parent Box
  235.  *    Object = Index of Slider
  236.  *    Direction = Direction of Slider 0 = Horz, 1=Vert
  237.  *
  238.  *    Return = Final position of slider [0,1000].
  239.  */
  240. int graf_slidebox(void *Tree,
  241.           int Parent, int Object, int Direction)
  242. {
  243.     _addrin[0] = Tree;
  244.     _int_in[0]    = Parent;
  245.     _int_in[1]    = Object;
  246.     _int_in[2]    = Direction;
  247.  
  248.     return __aes__(AES_CONTROL_ENCODE(76, 3, 1, 1));
  249. }
  250. #endif /* L_graf_sli */
  251.  
  252. #ifdef L_graf_han
  253.  
  254. /* get VDI handle for workstation
  255.  * Wchar,Hchar    size of system font char cell
  256.  * Wbox, Hbox    size of box to contain char
  257.  *
  258.  * returns VDI handle
  259.  */
  260. int graf_handle(int *Wchar, int *Hchar, int *Wbox, int *Hbox)
  261. {
  262.     int handle = __aes__(AES_CONTROL_ENCODE(77, 0, 5, 0));
  263.  
  264.     *Wchar = _int_out[1];
  265.     *Hchar = _int_out[2];
  266.     *Wbox  = _int_out[3];
  267.     *Hbox  = _int_out[4];
  268.  
  269.     return handle;
  270. }
  271. #endif /* L_graf_han */
  272.  
  273.  
  274. #ifdef L_graf_mou
  275.  
  276. /*
  277.  * Mouse Forms
  278.  *    0    arrow
  279.  *    1    text cursor (vert bar)
  280.  *    2    Hour Glass
  281.  *    3    Pointed finger
  282.  *    4    Flat Hand
  283.  *    5    Thin crosshair
  284.  *    6    Thick crosshair
  285.  *    7    outline crosshair
  286.  *    255 Mouse form in FormAddress
  287.  *    256 Hide Mouse
  288.  *    257 Show Mouse
  289.  *
  290.  *    return ==0 error    >0 no error
  291.  */
  292. int graf_mouse(int Form, void *FormAddress)
  293. {
  294.     _int_in[0]    = Form;
  295.     _addrin[0] = FormAddress;
  296.  
  297.     return __aes__(AES_CONTROL_ENCODE(78, 1, 1, 1));
  298. }
  299. #endif /* L_graf_mou */
  300.  
  301. #ifdef L_graf_mks
  302.  
  303. /* Get mouse/kbd info
  304.  *    Mx        Current X pos of mouse
  305.  *    My        Current Y pos of mouse
  306.  *    ButtonState     State of mouse buttons lsb==leftmost button & so on...
  307.  *    KeyState    State of kbd Shift and Alt keys
  308.  *                 1- right shift  2-left shift
  309.  *                 4- Ctrl         8-Alt
  310.  *                 Bit = 0 key up  = 1 key down
  311.  *
  312.  *    returns a reserved value
  313.  */
  314. int graf_mkstate(int *Mx, int *My, int *ButtonState, int *KeyState)
  315. {
  316.     int retval;
  317.  
  318.     retval = __aes__(AES_CONTROL_ENCODE(79, 0, 5, 0));
  319.  
  320.     *Mx      = _int_out[1];
  321.     *My      = _int_out[2];
  322.     *ButtonState = _int_out[3];
  323.     *KeyState     = _int_out[4];
  324.  
  325.     return retval;
  326. }
  327. #endif /* L_graf_mks */
  328.  
  329. /* - eof - */
  330.